<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>RF24 Library for 16 bit PIC MCUs: rf_spi.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">RF24 Library for 16 bit PIC MCUs
   </div>
   <div id="projectbrief">This library aims to provide PIC24 and dsPIC users an easy way to interface with the popular RF24 series chips from Nordic Semiconductor. It was developed originally as a direct port of maniacbug&#39;s Arduino RF24 library, but I went beyond that in order to increase speed for my application. The end result is a fast and easy to use library that leverages the improved speed and peripheral features present in 16 bit PIC MCUs.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">rf_spi.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Header file declaring various SPI functions for use with the RF24 LIbrary.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;xc.h&gt;</code><br />
<code>#include &lt;stdint.h&gt;</code><br />
<code>#include &lt;stdbool.h&gt;</code><br />
</div>
<p><a href="rf__spi_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:ae506139af46f1328f631ddacd54af96d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae506139af46f1328f631ddacd54af96d"></a>enum &#160;</td><td class="memItemRight" valign="bottom"><b>SPI_MODE</b> { <b>SPI_8BIT</b> = 0, 
<b>SPI_16BIT</b> = 1
 }</td></tr>
<tr class="separator:ae506139af46f1328f631ddacd54af96d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a35736310ee6ad14f2aa1bfa3d62c61dd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rf__spi_8h.html#a35736310ee6ad14f2aa1bfa3d62c61dd">spi_init</a> (SPI_MODE mode, volatile uint16_t *SS_REG, uint8_t SS_pin)</td></tr>
<tr class="separator:a35736310ee6ad14f2aa1bfa3d62c61dd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a021d3d71d7de4dde682dd55fbc0c2e71"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rf__spi_8h.html#a021d3d71d7de4dde682dd55fbc0c2e71">spi_write8</a> (const uint8_t byte)</td></tr>
<tr class="separator:a021d3d71d7de4dde682dd55fbc0c2e71"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af27e39df5f7f65da4878d5a3cfb1d830"><td class="memItemLeft" align="right" valign="top">uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rf__spi_8h.html#af27e39df5f7f65da4878d5a3cfb1d830">spi_write16</a> (const uint16_t word)</td></tr>
<tr class="separator:af27e39df5f7f65da4878d5a3cfb1d830"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae3f683d9d5b5d9542895dcbe0cb269b0"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rf__spi_8h.html#ae3f683d9d5b5d9542895dcbe0cb269b0">spi_write</a> (uint8_t command, const uint8_t *buf, uint8_t len)</td></tr>
<tr class="separator:ae3f683d9d5b5d9542895dcbe0cb269b0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a098ee1e29d7d291d7d452729cccd7f51"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rf__spi_8h.html#a098ee1e29d7d291d7d452729cccd7f51">spi_read</a> (uint8_t command, uint8_t nopChar, uint8_t *buf, uint8_t len)</td></tr>
<tr class="separator:a098ee1e29d7d291d7d452729cccd7f51"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afe4fa4827707bf89700f67434d84dd84"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rf__spi_8h.html#afe4fa4827707bf89700f67434d84dd84">spi_write8_no_ss</a> (const uint8_t byte)</td></tr>
<tr class="separator:afe4fa4827707bf89700f67434d84dd84"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3a40417d3c838323f58ba9eeaa7188ef"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rf__spi_8h.html#a3a40417d3c838323f58ba9eeaa7188ef">spi_write_no_ss</a> (const uint8_t *buf, uint8_t len)</td></tr>
<tr class="separator:a3a40417d3c838323f58ba9eeaa7188ef"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af22734746aa8440e525d93dc5626b3f8"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rf__spi_8h.html#af22734746aa8440e525d93dc5626b3f8">spi_read_no_ss</a> (uint8_t command, uint8_t nopChar, uint8_t *buf, uint8_t len)</td></tr>
<tr class="separator:af22734746aa8440e525d93dc5626b3f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af40c9e8c67ebdfc55465a3503591465d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rf__spi_8h.html#af40c9e8c67ebdfc55465a3503591465d">spi_ss</a> (bool state)</td></tr>
<tr class="separator:af40c9e8c67ebdfc55465a3503591465d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Header file declaring various SPI functions for use with the RF24 LIbrary. </p>
<dl class="section author"><dt>Author</dt><dd>Jeff Eaton </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a35736310ee6ad14f2aa1bfa3d62c61dd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void spi_init </td>
          <td>(</td>
          <td class="paramtype">SPI_MODE&#160;</td>
          <td class="paramname"><em>mode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">volatile uint16_t *&#160;</td>
          <td class="paramname"><em>SS_REG</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>SS_pin</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Initialize SPI stuff</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">mode</td><td><code>SPI_8BIT</code> for byte transfers, <code>SPI_16BIT</code> for word transfers </td></tr>
    <tr><td class="paramname">SS_REG</td><td>pointer to the LAT register that drives the slave select pin </td></tr>
    <tr><td class="paramname">SS_pin</td><td>which bit in that register drives the slave select pin </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a098ee1e29d7d291d7d452729cccd7f51"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t spi_read </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>command</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>nopChar</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Write null characters over SPI to read multi-byte data sent from a peripheral. A command byte will be sent first, followed by <code>len</code> iterations of <code>nopChar</code>. Received data will be stored at <code>buf</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">command</td><td>Command byte to send prior to receiving data </td></tr>
    <tr><td class="paramname">nopChar</td><td>Null character to write in order to receive data back </td></tr>
    <tr><td class="paramname">buf</td><td>Where to store the received data. </td></tr>
    <tr><td class="paramname">len</td><td>Number of bytes to read </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Byte received when the command byte is written </dd></dl>

</div>
</div>
<a class="anchor" id="af22734746aa8440e525d93dc5626b3f8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t spi_read_no_ss </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>command</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>nopChar</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Same as spi_read, but doesn't do anything with the slave select pin.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="rf__spi_8h.html#a098ee1e29d7d291d7d452729cccd7f51">spi_read</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">command</td><td>Command byte to transfer </td></tr>
    <tr><td class="paramname">nopChar</td><td>Null byte to send in order to receive </td></tr>
    <tr><td class="paramname">buf</td><td>Where to store the received data </td></tr>
    <tr><td class="paramname">len</td><td>Number of bytes to read </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Byte received when the command byte was written </dd></dl>

</div>
</div>
<a class="anchor" id="af40c9e8c67ebdfc55465a3503591465d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void spi_ss </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>state</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Manually drive the slave select pin high or low.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">state</td><td>True to drive slave select high, false to drive slave select low. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ae3f683d9d5b5d9542895dcbe0cb269b0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t spi_write </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>command</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Write a command byte <code>command</code>, followed by <code>len</code> bytes of data stored in <code>buf</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">command</td><td>Byte to write first </td></tr>
    <tr><td class="paramname">buf</td><td>Data to send after the command byte </td></tr>
    <tr><td class="paramname">len</td><td>Number of bytes to send (not including command byte) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Byte received when the command byte is written </dd></dl>

</div>
</div>
<a class="anchor" id="af27e39df5f7f65da4878d5a3cfb1d830"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint16_t spi_write16 </td>
          <td>(</td>
          <td class="paramtype">const uint16_t&#160;</td>
          <td class="paramname"><em>word</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Write a single 16 bit word. The slave select pin will first be driven low, followed by the clock and data pulses, followed by the slave select pin returning high. Data transfered back from the device (MISO pin) will be returned.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">word</td><td>Word to send to device (mcu-&gt;peripheral) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Word sent by device (peripheral-&gt;mcu) </dd></dl>

</div>
</div>
<a class="anchor" id="a021d3d71d7de4dde682dd55fbc0c2e71"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t spi_write8 </td>
          <td>(</td>
          <td class="paramtype">const uint8_t&#160;</td>
          <td class="paramname"><em>byte</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Write a single byte. The slave select pin will first be driven low, followed by the clock and data pulses, followed by the slave select pin returning high. Data transfered back from the device (MISO pin) will be returned.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">byte</td><td>Byte to send TO device (mcu-&gt;peripheral) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Byte sent BY device (peripheral-&gt;mcu) </dd></dl>

</div>
</div>
<a class="anchor" id="afe4fa4827707bf89700f67434d84dd84"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t spi_write8_no_ss </td>
          <td>(</td>
          <td class="paramtype">const uint8_t&#160;</td>
          <td class="paramname"><em>byte</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Same as spi_write8, but doesn't do anything with the slave select pin.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="rf__spi_8h.html#a021d3d71d7de4dde682dd55fbc0c2e71">spi_write8</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">byte</td><td>Byte to send </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Byte received when <code>byte</code> is sent </dd></dl>

</div>
</div>
<a class="anchor" id="a3a40417d3c838323f58ba9eeaa7188ef"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t spi_write_no_ss </td>
          <td>(</td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Same as spi_write, but doesn't do anything with the slave select pin. There also isn't a command byte, because you could just call spi_write8_no_ss prior to this and after driving slave select low.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="rf__spi_8h.html#ae3f683d9d5b5d9542895dcbe0cb269b0">spi_write</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">buf</td><td>Data to write </td></tr>
    <tr><td class="paramname">len</td><td>Number of bytes to write </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the byte received when the last data byte is sent </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Feb 20 2015 20:21:27 for RF24 Library for 16 bit PIC MCUs by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>
